package com.aceitunaproject.server.translator;

import java.util.LinkedList;
import java.util.List;

import com.aceitunaproject.shared.gamelement.Installation;
import com.aceitunaproject.shared.playerdata.PlayerData;

/**
 * 
 * Translation from Installation server object to shared object
 * 
 * @author Federico Bergstein
 */
public class InstallationTranslator {

	public static List<Installation> ListToShared(
			List<com.aceitunaproject.server.entity.installation.Installation> installations) {
		
		List<Installation> retList = new LinkedList<Installation>();
		
		for(com.aceitunaproject.server.entity.installation.Installation inst : installations)
		{
			retList.add(toShared(inst));
		}
		
		return retList;
		
		
	}

	private static Installation toShared(
			com.aceitunaproject.server.entity.installation.Installation from) {
		
		Installation to = new Installation();
		to.setId(from.getId());
	    to.setType(from.getInstallationType().getDefaultName());
		to.setName(from.getName());
		to.setPlayer(new PlayerData());
		to.setComplete(from.isComplete());
		to.getPlayer().setName(from.getOwner().getName());
		to.setPositionX(from.getCurrentPosition().x);
		to.setPositionY(from.getCurrentPosition().y);	
		return to;
	}
	
	

}
